package lee.lxwei.boot.service;

import lee.lxwei.boot.domain.UserLoginOutEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;

/**
 * 用户退出
 */
@Slf4j
@Service
public class UserLoginService {

    /**
     * 注入 事件发布类
     */
    @Autowired
    ApplicationEventPublisher eventPublisher;

    public boolean loginOut(String name) {
        log.info("用户登出 {} 并以事件处理后续任务", name);
        //发送事件
        eventPublisher.publishEvent(UserLoginOutEvent.builder().name(name).build());
        return true;
    }
}
